package org.lc.eic.synchronizer.requestdispatcher;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import org.lc.eic.core.pipesandfilters.Pipe;
import org.lc.eic.core.pipesandfilters.exception.ProcessingException;

public class MockBlockingPipe<I> implements Pipe<I> {
	
	private BlockingQueue<I> queue = new LinkedBlockingQueue<I>();
	
	public void process(I msg) throws ProcessingException {
		try {
			queue.put(msg);
		} catch (InterruptedException e) {
			throw new ProcessingException("Interrupted!", e);
		}

	}

	public I take(){
		try {
			return queue.take();
		} catch (InterruptedException e) {			
			e.printStackTrace();
			return null;
		}
	}
	
	public boolean isEmpty(){
		return queue.isEmpty();
	}
	
	

}
